package oop2;

/**
 * @author oldliu
 * @since 1.0
 */
//班级信息
public class JavaClass {
    String name;
    String dirTeacher;
    //最多30个学生
    String stus[] = new String[30];

    public void add(String newStu) {
        for (int i = 0; i < stus.length; i++) {
            if (stus[i] == null)//空位置
            {
                stus[i] = newStu;
                return;
            }
        }
        System.out.println("座位已满");
    }

    //查找指定的姓名，在不在
    public boolean search(String sname) {
        for (int i = 0; i < stus.length; i++) {
            if (sname.equals(stus[i])) {//if(stus[i]!=null&&stus[i].equals(sname))
                return true;//在！
            }
        }
        return false;//不在！
    }

    //按照区间查找在不在？
    public boolean search2(int start, int end, String sname) {
        for (int i = start; i >= 0 && i <= end && end < stus.length; i++) {
            if (sname.equals(stus[i])) {
                return true;
            }
        }
        return false;
    }

    public void show() {
        System.out.println("班级" + name + "情况：");
        System.out.println("指导老师：" + dirTeacher);
        System.out.println("学生信息如下:");
        for (int i = 0; i < stus.length; i++) {
            if (stus[i] == null)
                break;

            System.out.print(stus[i] + " ");
        }
        System.out.println();
    }
}
